removed gl .c files
[EroBeats.git] / Djinn and Tonic - Erobeats / Fonts.cpp
blob42f372038280958bf8a69ba635344212c7006681
1 #include "Fonts.h"
3 Fonts::Fonts() {
7 Fonts::Fonts(int fontType, ResourceMaster* rescources){
8 TTF_Init();
9 switch (fontType) {
10 case 0:
11 font = TTF_OpenFont("Fonts/Roboto-Black.ttf", 78);
12 break;
13 case 1:
14 font = TTF_OpenFont("Fonts/Cirno.ttf", 78);
15 break;
18 rsc = rescources;
20 renderer = rsc->rendPtr;
22 SDL_GetWindowSize(rsc->window, &windowWidth, &windowHeight);
26 Fonts::Fonts(int fontType, ResourceMaster* rsc, SDL_Color color, std::string words, int rendering)
29 TTF_Init();
30 switch (fontType) {
31 case 0:
32 font = TTF_OpenFont("Fonts/Roboto-Black.ttf", 28);
33 break;
36 loadFont(color, words, rendering);
38 renderer = rsc->rendPtr;
39 SDL_GetWindowSize(rsc->window, &windowWidth, &windowHeight);
43 Fonts::~Fonts()
47 void Fonts::changeColor() {
51 void Fonts::loadFont(SDL_Color color, std::string words, int rendering) {
52 SDL_Surface* textSurface;
53 //3 for outline, 2 for high, 1 for BG 0 for low, default low
54 if (rendering == 0) {
55 textSurface = TTF_RenderText_Solid(font, words.c_str(), color);
57 else if (rendering == 1) {
58 textSurface = TTF_RenderText_Shaded(font, words.c_str(), color, SDL_Color{ 255,255,255 });
60 else if (rendering == 2) {
61 textSurface = TTF_RenderText_Blended(font, words.c_str(), color);
63 else if (rendering == 3) {
64 TTF_SetFontOutline(font, 1);
65 textSurface = TTF_RenderText_Blended(font, words.c_str(), color);
66 TTF_SetFontOutline(font, 0);
68 else {
69 textSurface = TTF_RenderText_Solid(font, words.c_str(), color);
74 if (textSurface == NULL) {
75 std::cout << TTF_GetError() <<"\n";
77 fontTexture = SDL_CreateTextureFromSurface(renderer, textSurface);
79 SDL_FreeSurface(textSurface);
82 int Fonts::prcnt(double location, char axis) {
83 switch (axis) {
84 case 'x':
85 return location * windowWidth;
86 case 'y':
87 return location * windowHeight;
88 default:
89 return 0;
94 void Fonts::updateWindow() {
95 SDL_GetWindowSize(rsc->window, &windowWidth, &windowHeight);
98 SDL_Texture* Fonts::getTexture() {
99 return fontTexture;
102 SDL_Rect* Fonts::getPosition() {
103 return location;